home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Set clock command *)
- (* *)
- (* Copyright 1990 by H. Roy Engehausen. All rights reserved. *)
- (* This software may be freely distributed and used, but it may not *)
- (* under any circumstances be sold by anyone other than the author. *)
- (* It may be distributed by a commercial company as long as it is *)
- (* for no cost. *)
- (* *)
- (*===========================================================================*)
-
- PROCEDURE set_clock(cmd_string : STRING);
-
- VAR
- out_dt : DATETIME;
- word_count : BYTE;
-
- FUNCTION get_num(low_bound : BYTE;
- high_bound : BYTE) : WORD;
-
- VAR
- code : INTEGER;
- i : INTEGER;
- s : STRING[2];
-
- BEGIN;
-
- s := COPY(cmd_string, 1, 2);
- cmd_string := COPY(cmd_string, 3, 255);
-
- VAL(s, i, code);
-
- IF (code <> 0) OR (i < low_bound) OR (i > high_bound) THEN
- BEGIN;
-
- send_tnc_data_str('Invalid number -- ' + s + cr);
-
- active_tcb^.error_sw := TRUE;
- get_num := 0;
-
- END
- ELSE
- get_num := i;
-
- END;
-
- BEGIN;
-
- strip_var(cmd_string, 'B');
-
- word_count := words(cmd_string);
-
- IF word_count = 1 THEN
- BEGIN;
- send_tnc_data_str(todays_date_time + cr);
- EXIT;
- END;
-
- IF cmd_string[2] <> ' ' THEN
- BEGIN;
- send_message(message_err_2nd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF word_count > 2 THEN
- BEGIN;
- send_message(message_err_wrd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF word_count < 2 THEN
- BEGIN;
- send_message(message_not_en);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- cmd_string := subword(@cmd_string, 2, 1);
-
- IF LENGTH(cmd_string) <> 10 THEN
- BEGIN;
- send_tnc_data_str('Date must be YYMMDDHHMM');
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- out_dt.year := 1900 + get_num(90, 99);
- IF active_tcb^.error_sw THEN
- EXIT;
-
- out_dt.month := get_num(1, 12);
- IF active_tcb^.error_sw THEN
- EXIT;
-
- out_dt.day := get_num(1, 31);
- IF active_tcb^.error_sw THEN
- EXIT;
-
- out_dt.hour := get_num(0 ,23);
- IF active_tcb^.error_sw THEN
- EXIT;
-
- out_dt.min := get_num(0 ,59);
- IF active_tcb^.error_sw THEN
- EXIT;
-
- SETDATE(out_dt.year, out_dt.month, out_dt.day);
- SETTIME(out_dt.hour, out_dt.min , 0, 0);
-
- send_message(message_op_complete);
-
- END;